using tenary operator to reduce code complexity
refactored
typo
typo 2
Merge pull request #1 from PirosB3/master

High order function and generalisation of the code