fixed code based on julians request