Cleaned up code