Cleans the code a bit, compacts several lines

Some of the code is duplicated. There's a lot that can be simplified. This is just one example.
Merge pull request #23 from ivanperez-keera/patch-1

Cleans the code a bit, compacts several lines