Cleaned up code (removed pointless repeated code)