Convert crap to function