Cleaned up code a bit
Removed duplicates