Merged ApiController with RealmsController - refactored logic to be simpler