refactor repeated code and position tweaks