FOUND ALL THE BUGS. Still need a test fucntion