base working codef