refactor, made nicer