fixed bug with missing param
added comments for logic