Updated the code to be compatible with CocoaScript

Signed-off-by: Thomas Seng Hin Mak <makzan@gmail.com>