Fixed buggered code