add dev/non dev mode and refactor a bit