Fixed and made more stable