complete working functionality