Optimizzation fixed. Added allerts