cleaned up source code a bit