cleaned up code, i hope