Kinda works, needs checks for errors
Better error checks added