extract logic