Tested function

Function performs properly in browser