Fixed improper updating bug, streamlined code a bit