Resorted functions and added spaces where needed