build: refactoring build scripts for better handling