fixed function to accept variables