Cleaned up code and added description on top