Optimised code for pagodabox