debugged
Tested on my computer