cleaned up code, much more neat now