Refined logic, still not working