fixed a small bug
cleaned up the code