I recently came across a similar situation as yours in my questionmy question
The person that answered my question did give me an advice of where I was going wrong with my approach, and also provided an alternative for it.
His solution didn't work as you can read in the comments. Few days past by and I was still doing research to find a solution to my problem and came across one.
I did feel it necessary to edit his post for the following reasons:
- His contribution to the code is greater than mine (to make it work)
- If it wasn't for his original answer, I wouldn't be able to do more research towards the correct one.
- I felt that he deserves the credit because of the previous reasons, and that an edit is more appropriate so future users are able to obtain the code from one spot instead of having to scroll up and down and see what's better and why.