refactored, documented, cleaned