cleaned up the source code a bit