Cleaned up messy bits ahmed pointed out