Added check for undefined values in js action function