src: refractor code