code cleanup

not pretty but it works