changed some names and cleaned up the code a bit