fix query in magic method