cleaned up the code abit