Everything working, with cleaner code