core logic written