Cleaned up the code abit