Re-wrote to be much more simple