cleaned up code, slightly