Updated code, works now