Cleaning up code. Removed the window.location.href change to see if thats why the view was flickering. Seems redundant in the code.