Removed uneeded logic
Renamed some variables for clarity
Added more tests