refactored with replace temp with query