Syntax fix

Thanks mc10
Refactored code

Thanks andytuba