Refactored views and ajax