general logic written but does not work