refactor of init functions