@_tomsteele made my code less ugly

I kept a little of the ugly though.