changed order of return statement to hopefully make everything a bit faster