fineshed but still need debugging but works in generail