worked on the core function