Updated formatting and cleaned up code