Clean up code to actually work