Cleaned up code and formatted structure