add tests
refactor
do not make temporary vars if not necessary
refactor