adjusted function to match jQuery standard function format