some tweaks, going into more functional approach