refactored, cleaned up a bit